package ifi.sma.group5.models;

import ifi.sma.group5.db.Db;

import java.util.ArrayList;
import java.util.Map;




public class QuestionModel {
	public int IdQuestion = -1;
	public String DescriptionQuestion;
	public int IdCours;
	public String Niveau;
	public String Op1;
	public String Op2;
	public String Op3;
	public String Op4;
	public String Reponse;

	public QuestionModel() {

	}

	public QuestionModel(String IdCours, String Niveau) {
		if (IdCours.equals("") || Niveau.equals(""))
			return;
		try {
			//AID = name;
			//name = name.substring(0, name.indexOf("@"));
			Db db = new Db("Question");
			ArrayList<Map<String, String>> datas = db.get(
					"SELECT * FROM Question WHERE IdCours=?", IdCours);
			if (datas.size() > 0) {
				this.IdQuestion = Integer.parseInt(datas.get(0).get("IdQuestion"));
				this.Niveau = datas.get(0).get("Niveau");
				this.Op1 = datas.get(0).get("Op1");
				this.Op2 = datas.get(0).get("Op2");
				this.Op3 = datas.get(0).get("Op3");
				this.Op4 = datas.get(0).get("Op4");
				this.Reponse = datas.get(0).get("Reponse");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
